package PTA_5;

import java.util.Scanner;

public class t7 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        String IP = scan.next();
        String key = "\\d+\\." +
                "\\d+\\." +
                "\\d+\\." +
                "\\d+";
        if(IP.matches(key)) {
            String[] s = IP.split("\\.",4);
            for (int i = 0; i < s.length; i++) {
                Integer num = new Integer(s[i]);
                if(num < 0 || num > 255) {
                    System.out.println(IP + "不是合法的IP地址");
                    return;
                }
            }
            System.out.println(IP + "是合法的IP地址");
        } else {
            System.out.println(IP + "不是合法的IP地址");
        }
    }
}
